import 'package:flutter/material.dart';
import "package:get/get.dart";

class LiveSeeting extends StatelessWidget {
  
  RxList<Map> items = [
    {'text': "无", "index": 0},
    {'text': "1", "index": 1},
    {'text': "2", "index": 2},
    {'text': "3", "index": 3},
  ].obs;

  final RxInt _index = 0.obs;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Color(0xfff5f5f5),
        leadingWidth: 40,
        leading: IconButton(
          onPressed: () {
            Get.back();
          },
          icon: Image.asset('static/images/back.png'),
        ),
        title: Text('直播设置',style: TextStyle(fontSize: 16)),
      ),
      body: Column(
        children: [
          Container(
            color: Color(0xfff5f5f5),
            height: 20,
          ),
          Container(
            transform: Matrix4.translationValues(0.0, -10.0, 0.0),
            decoration: BoxDecoration(
                color: Color(0xffffffff),
                borderRadius: BorderRadius.circular(20)),
            height: 20,
          ),
          SizedBox(height: 50,),
          Container(
            padding: EdgeInsets.only(left: 15),
            child: Row(
              children: [
                Text('直播标题'),
                SizedBox(width: 20),
                Expanded(
                  child: TextField(
                    textAlign: TextAlign.left, // 文本右对齐
                    style: TextStyle(fontSize: 12),
                    decoration: InputDecoration(
                      hintStyle:
                          TextStyle(fontSize: 12, color: Color(0xff999999)),
                      border: InputBorder.none, // 隐藏输入框默认边框
                      hintText: '请输入直播标题', // 提示文本
                    ),
                  ),
                )
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(bottom: 50,top: 50),
            padding: EdgeInsets.only(left: 15),
            child: Row(
              children: [
                Text('选择封面'),
                SizedBox(width: 20),
                Container(
                  width: 80,
                  height: 150,
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(10),
                      color: Color(0xfff5f5f5)),
                  child: IconButton(
                    iconSize: 30,
                    icon: Icon(Icons.add),
                    color: Color(0xffdddddd),
                    onPressed: () {
                      // 点击事件处理
                      print('加号被点击');
                    },
                  ),
                )
              ],
            ),
          ),

          Container(
            padding: EdgeInsets.only(left: 15),
            child: Row(
              children: [
                Text('美颜等级'),
                SizedBox(width: 20),
                Row(
                  children: [
                    for (var item in items)
                      GestureDetector(
                          onTap: () => {_index.value = item['index']},
                          child: Obx(
                            () => Container(
                              margin: EdgeInsets.only(right: 10),
                              alignment: Alignment.center,
                              width: 30,
                              height: 30,
                              decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5),
                                  color: _index.value == item['index']
                                      ? Color(0xffEBE2FF)
                                      : Color(0xfff2f2f2),
                                  border: _index.value == item['index']
                                      ? Border.all(color: Color(0xff6A3BD9))
                                      : Border.all(color: Color(0xfff2f2f2))),
                              child: Text(item['text']),
                            ),
                          )),
                  ],
                )
              ],
            ),
          ),
          Expanded(child: Container()),

          GestureDetector(
            onTap: (){
              Get.dialog(
                AlertDialog(
                  backgroundColor: Colors.transparent,
                  content: Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(15.0),
                        child: Image.asset(
                          'static/qidai.png',
                          width: 250,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ],
                  ),
                ),
              );
            },
            child: Container(
            width: 260,
            height: 50,
            margin: EdgeInsets.only(bottom: 20),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular((50)),
              gradient: LinearGradient(
                colors: [
                  Color(0xff2189E7),
                  Color(0xffBF67F8),
                ], // 定义颜色列表
                begin: Alignment.topLeft, // 渐变开始的位置
                end: Alignment.bottomRight, // 渐变结束的位置
              ),
            ),
            child: Text('开启直播',style: TextStyle(color: Color(0xffffffff)),),
          ),
          )
          

        ],
      ),
    );
  }
}
